{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "# Train / Test"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "We'll start by creating some data set that we want to build a model for (in this case a polynomial regression):"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x1c4457ae940>"
      ]
     },
     "execution_count": 1,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAG0RJREFUeJzt3X+MHOd93/H3h8eLdLLTkImugnQyS7mQWVhxQsIHoQUj\nw1JqU4kdmXYAWWrrOo0R2oBrRKrAlHQBS21imCijKAXSuKBrQQ7iyFQiiVEtN6xiuhEixLGPPuqX\nJTaSLdU8MeLZ0tlOdBVO5Ld/3C69t9zZnZ2d2Zmd/bwAgndz++PZ273PPPN9nnlGEYGZmdXXurIb\nYGZmxXLQm5nVnIPezKzmHPRmZjXnoDczqzkHvZlZzTnozcxqzkFvZlZzDnozs5pbX3YDAC688MLY\nvHlz2c0wMxspR48e/W5ETPe6XSWCfvPmzczNzZXdDDOzkSLp+TS3c+nGzKzmHPRmZjXnoDczqzkH\nvZlZzTnozcxqrhKzbrI6NL/A/sPHeWFpmUs2TLF7xxZ2bpspu1lmZpUyskF/aH6Bvfc9zvLKaQAW\nlpbZe9/jAA57M7MWI1u62X/4+NmQb1peOc3+w8dLapGZWTWNbNC/sLTc13Yzs3E1skF/yYapvrab\nmY2rkQ363Tu2MDU5sWbb1OQEu3dsKalFZmbVNLKDsc0BV8+6MTPrrmfQS7oTeDdwKiJ+urHtINDs\nOm8AliJiq6TNw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85yPivrLbM2wRsQQ8CIxE\n/Taj7cB1kp4DvgBcI+kPy23ScETEQuP/U8D9wJXltqg3B73lSpKAzwJPRcTvlN2eYZE0LWlD4+sp\n4B3AsXJbVZyI2BsRl0bEZuAG4EhE/KuSm1U4Sa+T9OPNr4F3ApUv0TnoCyTpbuCvgC2STkj6UNlt\nGoLtwAdY7eEda/z7xbIbNQQXA1+R9CjwNeCLEfFQyW2y/F0E/GXL+/xgRPxZyW3qyWfGmpnVnHv0\nZmY156A3M6s5B72ZWc056M3Mas5Bb2ZWcw56M7Oac9CbmdWcg97MrOb+P/wLFsxUk2aCAAAAAElF\nTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1c443b095f8>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "%matplotlib inline\n",
    "import numpy as np\n",
    "from pylab import *\n",
    "\n",
    "np.random.seed(2)\n",
    "\n",
    "pageSpeeds = np.random.normal(3.0, 1.0, 100)\n",
    "purchaseAmount = np.random.normal(50.0, 30.0, 100) / pageSpeeds\n",
    "\n",
    "\n",
    "scatter(pageSpeeds, purchaseAmount)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Now we'll split the data in two - 80% of it will be used for \"training\" our model, and the other 20% for testing it. This way we can avoid overfitting."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "trainX = pageSpeeds[:80]\n",
    "testX = pageSpeeds[80:]\n",
    "\n",
    "trainY = purchaseAmount[:80]\n",
    "testY = purchaseAmount[80:]\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Here's our training dataset:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x1c445b795c0>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGWlJREFUeJzt3X+QHGd95/H3x+uNWUOSdc4bl71GkUkZpXBIpMqWK1eK\nKewcyAFiBH/4Ry6EJFQEVYSKCaWcxFWB7xIK1SmOuapLuBKHy6QgRk5sKw52ojiYxBUqDqxYGdsY\nJTbYQWvFWrAXSLznW0vf+2Nn7NFqeqanf0z39HxeVSrN9s7sPDOz++mnv8/TTysiMDOz5jqj6gaY\nmVm5HPRmZg3noDczazgHvZlZwznozcwazkFvZtZwDnozs4Zz0JuZNZyD3sys4c6sugEA5557bmzc\nuLHqZpiZjZRDhw59OyJm+t2vFkG/ceNG5ufnq26GmdlIkfRkmvu5dGNm1nAOejOzhnPQm5k1nIPe\nzKzhHPRmZg1Xi1k3WR1YWGTvwSM8tbzCBdNT7Ny2ie1bZqtulplZrYxs0B9YWGT3HQ+xsnoCgMXl\nFXbf8RCAw97MrMPIlm72HjzyYsi3rayeYO/BIxW1yMysnkY26J9aXhlou5nZuBrZoL9gemqg7WZm\n42pkg37ntk1MTU6csm1qcoKd2zZV1CIzs3oa2cHY9oCrZ92YmfXWN+gl3Qy8BTgeET/Z2rYfaHed\np4HliNgsaSPwKNAeEX0gIt5TdKPbtm+ZdbCbmfWRpkd/C/C/gD9ub4iIa9q3Jd0IfLfj/o9HxOai\nGmhmZvn0DfqIuL/VUz+NJAFXA1cU2ywzMytK3sHYy4CnI+KfO7ZdJOmwpL+TdFnSAyXtkDQvaX5p\naSlnM8zMLEneoL8OuLXj62PAhlbp5reBP5H0Q90eGBH7ImIuIuZmZvpeIMXMzDLKHPSSzgTeDuxv\nb4uI5yPiO63bh4DHgVfnbaSZmWWX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jTX/\n1vpyEpgAnq2wSaWTdCHwZuD/VN0W681Bb6WRtBHYAvxjtS0ZjlYZ4zBwHPjbiGh6ye5jwO8AJ6tu\nyJAF8DeSDknaUXVj0nDQWykkvQK4Hbg+Ir5XdXuGISJORMRm4ELgMkmXV92mskh6C3A8Ig5V3ZYK\n/Fzrc/4F1kqTr6u6Qf046K1wkiZZC/nPRMQdVbdn2CJiGbgbGIn6bUZbgaskPQF8FrhC0qerbdJw\nRMRi6//jwJ3ApdW2qD8HvRVKkoBPAo9GxB9U3Z5hkTQjabp1ewp4A3C42laVJyJ2R8SFEbERuBa4\nLyJ+ueJmlU7SyyX9YPs28Eag9iU6B32JJN0K/AOwSdJRSe+quk1DsBV4B2s9vMOtf2+qulFDcD7w\nBUkPAl8CPhcR91bcJiveecDfd3zOd0fEX1Xcpr58ZqyZWcO5R29m1nAOejOzhnPQm5k1nIPezKzh\nHPRmZg3noDczazgHvZlZwznozcwa7v8DlcE99iAJUowAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1c443aece10>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "scatter(trainX, trainY)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "And our test dataset:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x1c445be8320>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEj5JREFUeJzt3W+MXFd5x/HvgzFiBbSbKFvX3pA6lSJXqVJwtKK0Lgga\nUlOg2IqqCCSohSJZrV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},
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "scatter(testX, testY)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Now we'll try to fit an 8th-degree polynomial to this data (which is almost certainly overfitting, given what we know about how it was generated!)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "x = np.array(trainX)\n",
    "y = np.array(trainY)\n",
    "\n",
    "p4 = np.poly1d(np.polyfit(x, y, 8))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Let's plot our polynomial against the training data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8VPW9//HXJyGBhC0gYQuyCIgKKtS4gVKXW1HbKmqv\nQtVqF7Ct15bfvT8saO+j+GutWK719lGXPlCx2roLUlxuqa3eui9sgijIImjCFggRAhGyfH5/nJkw\nhJlkZs45OTNnPs/HI49Jzpw5880Q3vOdz/l+v0dUFWOMMeGVF3QDjDHG+MuC3hhjQs6C3hhjQs6C\n3hhjQs6C3hhjQs6C3hhjQq7NoBeRo0XkVRH5SERWi8hPI9t7isjLIrIuctsj5jEzRWS9iKwVkQl+\n/gLGGGNaJ22NoxeRfkA/VV0mIl2BpcBE4HqgWlVni8gMoIeq/kxETgCeAE4D+gN/B45V1UYffw9j\njDEJtNmjV9Wtqros8v1e4GOgDLgUeCSy2yM44U9k+5OqekBVPwXW44S+McaYAHRIZWcRGQyMAd4F\n+qjq1shd24A+ke/LgHdiHlYR2dbyWFOBqQ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ORjEZkddJvSISL5IrJcRF4Iui2pEpFNIrJK\nRFYkO8wvk4hIiYg8KyJrIn9DZwbdpmSJyIjI6x792iMi0xLuH2SNPrJUwifELJUATM6WpRJEZDxQ\nCzyqqqOCbk+qRKQf0E9Vl4lIV2ApMDEbXn8REaCzqtaKSAHwBvB/VfX1gJuWEhH5d6Ac6Kaq3wi6\nPakQkU1Auapm5YQjEXkEeF1VH4yMDixW1Zqg25WqSI5W4kxK3Rxvn6B79M1LJajqQSC6VEJWUNXX\nANezMIOiqltVdVnk+73Ax0BWrNWgjtrIjwU4o7t2B9iklInIAODrwINBtyXXiEh3YDzwEICqHszG\nkI84H9iQKOQh+KAvA2Iva1NBlgRN2IjIYGAM8G6wLUlepOyxAtgB/K+qZlsJ7b+Bm4GmoBuSJgX+\nLiJLI0uaZJMhQBXwcKR09qCIdA66UWmaBDzR2g5BB73JACLSBZgPTFPVPUG3J1mq2qiqo3FmXp8t\nIucG3aZkicg3gB2qujTotrhwVuT1vwi4MVLKzBYdgK8A96vqGGAfkFXnCAEiJadLgGda2y/ooLel\nEgIWqW/PBx5T1QVBtycdkY/cL+LUurPFOOCSSJ37SeA8EflzsE1KjapWRm53AM/hlGKzRQVQoarR\nT7DP4gR/trkIWKaq21vbKeigt6USAhQ5ofkQ8LGq/jbo9qRCREpFpCTyfRHOCf0VwbYqeao6U1UH\nqOpgnL/7V1T1moCblTQR6Rw5gU+k5HEBWbQCrapuAz4XkehFCM4nO5dRn0wbZRsI+OLgaSyVkFFE\n5AngHKCXiFQAv1DVh4JtVUrGAdcCqyK1boBbVPWlANuUrH7AI+IsI5wH/FlVXw64TbmkD/Cc01eg\nA/C4qv412Cal7CbgsUgncyPw3YDbk5LIG+zXgBva3NeWQDDGmHALunRjjDHGZxb0xhgTchb0xhgT\nchb0xhgTchb0xhgTchb0xhgTchb0xhgTcv8fmxK6i64FMr8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1c445bbf128>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "\n",
    "xp = np.linspace(0, 7, 100)\n",
    "axes = plt.axes()\n",
    "axes.set_xlim([0,7])\n",
    "axes.set_ylim([0, 200])\n",
    "plt.scatter(x, y)\n",
    "plt.plot(xp, p4(xp), c='r')\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "And against our test data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3XucVXW9//HXBxgQhjuMMFyMi4h5KaiJEhVLjqLZycvj\nHJPSyl8nuvirfFSWlD0qz8PEQ9avR7cTKUUd1LzryUotb2mmDoIgInFRkxGGEUQYGLnN5/fHd41u\ncYbZs/das/Ze+/18PPZj71l77b0/Irz3d77rezF3R0REsqtH2gWIiEiyFPQiIhmnoBcRyTgFvYhI\nxinoRUQyTkEvIpJxnQa9mY01s/vN7BkzW2lmX4qODzWze81sTXQ/JOc1c81srZmtNrNZSf4HiIjI\nwVln4+jNrBaodfcnzWwAsAQ4C/gksNXd55nZpcAQd/+6mR0FXA9MA0YBfwaOcPf9Cf53iIhIBzpt\n0bv7Rnd/Mnq8A1gFjAbOBBZFpy0ihD/R8Rvcfbe7PwesJYS+iIikoFdXTjazccBU4DFghLtvjJ7a\nBIyIHo8G/p7zsg3RsQPfaw4wB6C6uvrdRx55ZFdKCbZtg3Xr4O1vh379uv56ESkPK1dC374wYULa\nlZSUJUuWvOzuNZ2dl3fQm1l/4BbgYnffbmavP+fubmZdWkvB3RcACwDq6uq8vr6+Ky8P7r0XTj0V\nFiyAE07o+utFpD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AossLNHbA/gfd7835ZoqyQjg\nttBWoBdwnbv/Kd2SuuwLwOKokbkeuDDlerok+oI9Beh0t3UtgSAiknFpd92IiEjCFPQiIhmnoBcR\nyTgFvYhIxinoRUQyTkEvIpJxCnoRkYz7/z5CW0JhEWTMAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1c445c7d198>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "testx = np.array(testX)\n",
    "testy = np.array(testY)\n",
    "\n",
    "axes = plt.axes()\n",
    "axes.set_xlim([0,7])\n",
    "axes.set_ylim([0, 200])\n",
    "plt.scatter(testx, testy)\n",
    "plt.plot(xp, p4(xp), c='r')\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Doesn't look that bad when you just eyeball it, but the r-squared score on the test data is kind of horrible! This tells us that our model isn't all that great..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.30018168612\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import r2_score\n",
    "\n",
    "r2 = r2_score(testy, p4(testx))\n",
    "\n",
    "print(r2)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "...even though it fits the training data better:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.642706951469\n"
     ]
    }
   ],
   "source": [
    "from sklearn.metrics import r2_score\n",
    "\n",
    "r2 = r2_score(np.array(trainY), p4(np.array(trainX)))\n",
    "\n",
    "print(r2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "If you're working with a Pandas DataFrame (using tabular, labeled data,) scikit-learn has built-in train_test_split functions to make this easy to do.\n",
    "\n",
    "Later we'll talk about even more robust forms of train/test, like K-fold cross-validation - where we try out multiple different splits of the data, to make sure we didn't just get lucky with where we split it."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "## Activity"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "deletable": true,
    "editable": true
   },
   "source": [
    "Try measuring the error on the test data using different degree polynomial fits. What degree works best?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
